package com.yangmin.springcloud.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.yangmin.springcloud.entities.CommonResult;
import com.yangmin.springcloud.entities.Payment;
import com.yangmin.springcloud.service.PaymentService;
import com.yangmin.springcloud.service.impl.PaymentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CircleBreakerController {
    @Autowired
    private PaymentService paymentService;

    @GetMapping("/comsumer/payment/{id}")
    @SentinelResource(value = "payment", blockHandlerClass = PaymentServiceImpl.class, blockHandler = "paymentSQL")
    public CommonResult<Payment> getPayment(@PathVariable("id") Long id) {
        return paymentService.paymentSQL(id);
    }
}
